<template>
  <ul class="video-list">
    <li v-for="video in videoList" :key="video.id">
      <p>{{ video.title }}</p>
      <video loop width="100%" controls>
        <source :src="video.video.url" />
      </video>
      <div class="nickName">
        <span> {{ video.user.nickName }}</span>
        <i @click="like($event, video)" class="iconfont">&#xe8ad;</i
        >{{ video.video.dur }} <i class="iconfont">&#xe825;</i
        >{{ video.upCount }}
        <i class="iconfont">&#xe8b0;</i>
      </div>
    </li>
  </ul>
</template>

<script>
import videoList from '@/mock/video.json'
export default {
  name: 'Video',
  data() {
    return {
      videoList: [],
    }
  },
  created() {
    this.videoList = videoList
  },
  methods: {
    like(e, video) {
      if (e.target.className === 'iconfont') {
        video.video.dur++
        e.target.className = 'iconfont  i-active'
      } else {
        video.video.dur--
        e.target.className = 'iconfont'
      }
    },
  },
}
</script>

<style lang="less" scoped>
@font-face {
  font-family: 'iconfont'; /* Project id 2728644 */
  src: url('//at.alicdn.com/t/font_2728644_buq0di4i3yj.woff2?t=1635251535375')
      format('woff2'),
    url('//at.alicdn.com/t/font_2728644_buq0di4i3yj.woff?t=1635251535375')
      format('woff'),
    url('//at.alicdn.com/t/font_2728644_buq0di4i3yj.ttf?t=1635251535375')
      format('truetype');
}
.iconfont {
  font-family: 'iconfont' !important;
  font-size: 18px;
  font-style: normal;
  -webkit-font-smoothing: antialiased;
  -webkit-text-stroke-width: 0.2px;
  -moz-osx-font-smoothing: grayscale;
}
.video-list {
  h3 {
    margin: 0;
    font-weight: normal;
  }
  li {
    position: relative;
    width: 100%;
    margin-bottom: 20px;
    p {
      padding: 0 30px;
      font-size: 14px;
      color: #fff;
      position: absolute;
      top: -10px;
      letter-spacing: 2px;
    }
    .nickName {
      padding: 0 40px;
      height: 60px;
      display: flex;
      justify-content: space-between;
      align-items: center;
      font-size: 16px;
      span {
        display: inline-block;
        width: 60%;
      }
      i {
        margin-top: -5px;
      }
      .i-active {
        color: #e54847;
      }
    }
  }
}
</style>
